package com.aerfafish.spider.spider;

import com.aerfafish.spider.graph.GraphUpdater;
import com.aerfafish.spider.neo4j.repository.FundHoldShareRepository;
import com.aerfafish.spider.neo4j.repository.FundRepository;
import com.aerfafish.spider.redis.CacheStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author aerfafish
 * @date 2020/12/17 4:34 下午
 */

@Component
public class MainExecutor {

    private final static Logger logger = LoggerFactory.getLogger(MainExecutor.class);

    private static ExecutorService executorService = Executors.newSingleThreadExecutor();

    @Autowired
    GraphUpdater graphUpdater;

    @Autowired
    FundRepository fundRepository;


    @Autowired
    CacheStorage cacheStorage;

    @Autowired
    FundHoldShareRepository fundHoldShareRepository;

    @PostConstruct
    void init() {

        execute();
    }

    public void execute() {

//        for(int i = 100000; i < 600000; i++) {
//
//            String fundCode = "" + i;
//            while (fundCode.length() < 6) {
//                fundCode = "0".concat(fundCode);
//            }
//            graphUpdater.updateFund(fundCode);
//        }
//        graphUpdater.updateFund("519602");
        // 010572
    }


}
